<template>
  <div>
    <iframe :src="src" ref="iframe" :height="height"  id="iframe_demo" style="width:100%;" frameborder="0"></iframe>
  </div>
</template>

<script>

let that
export default {
  data(){
    return {
      src:"",
      height:0,
    }
  },
  mounted(){
    that = this
    this.height = (document.body.clientHeight - 100)
    this.$nextTick(function(){
      this.src = this.url + `&new=${Math.random()}`
    })
  },
  watch:{
    url(e){
      this.src = e + `&new=${Math.random()}`
    },
  },
  updated(){
    
  },
  methods:{
    handleUrl(){
      this.src = ""
    },
    handleSave(){
      this.$emit('handleSave',{code:200})
    },
    handleEmit(e){
      console.log(e,"传的值")
      let iframe = document.getElementById('iframe_demo');
      iframe.contentWindow.postMessage(e, '*');
    },
  },
  props:{//编辑器的宽高取决于编辑器渲染节点本身的宽高
    url:{
      type:String,
      default:""
    },
  },
}
</script>

<style>

</style>